package kr.hkit.androidcomplete03.ch21;

import kr.hkit.androidcomplete03.R;
import android.app.ActionBar;
import android.app.Activity;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuInflater;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.ViewGroup.LayoutParams;
import android.widget.Button;
import android.widget.LinearLayout;
import android.widget.TextView;

public class ActionBarTest extends Activity {
	
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
//		requestWindowFeature(Window.FEATURE_ACTION_BAR);
		
		LinearLayout layout = new LinearLayout(this);
		layout.setOrientation(LinearLayout.VERTICAL);
		
		LayoutParams params = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT);
		
		TextView tv = new TextView(this);
		tv.setText("액션바를 테스트합니다.");
		
		layout.addView(tv, params);
		
		final Button btn = new Button(this);
		btn.setText("Hide ActionBar");
		btn.setOnClickListener(new OnClickListener() {
			public void onClick(View v) {
				ActionBar ab = getActionBar();
				if (ab.isShowing()){
					ab.hide();
					btn.setText("Show Action Bar");
				}else{
					ab.show();
					btn.setText("Hide Action Bar");
				}
			}
		});
		
		layout.addView(btn, params);
		setContentView(layout);
	}
	
	@Override
	public boolean onCreateOptionsMenu(Menu menu) {
		super.onCreateOptionsMenu(menu);
		
		MenuInflater inflater = getMenuInflater();
		inflater.inflate(R.menu.actionbarmenu, menu);
		return true;
	}
}
